home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / lang / sofa.lha / sofa / smalleiffel / lib_show / cecil / example2 / example.e < prev    next >
Text File  |  2000-03-25  |  994b  |  52 lines

  1. class EXAMPLE
  2.    --
  3.    -- The Eiffel program is running first, then call the C program
  4.    -- which is in charge to call the Eiffel feature `show_values' of
  5.    -- this EXAMPLE class.
  6.    --
  7.    -- To compile this example, use command :
  8.    --
  9.    --         compile -cecil cecil.se example c_prog.c
  10.    --
  11.    -- Is is also possible to do :
  12.    --
  13.    --         gcc -c c_prog.o
  14.    --         compile -cecil cecil.se example c_prog.o
  15.    --
  16.  
  17. creation make
  18.  
  19. feature
  20.  
  21.    make is
  22.       do
  23.          values := <<1,2,3>>;
  24.          call_c_prog(Current);
  25.       end;
  26.  
  27.    show_values is
  28.       local
  29.          i: INTEGER;
  30.       do
  31.          from
  32.             i := values.lower;
  33.          until
  34.             i > values.upper
  35.          loop
  36.             io.put_integer(values.item(i));
  37.             io.put_new_line;
  38.             i := i + 1;
  39.          end;
  40.       end;
  41.  
  42. feature {NONE}
  43.  
  44.    values: ARRAY[INTEGER];
  45.  
  46.    call_c_prog(current_object: like Current) is
  47.       external "C"
  48.       alias "c_prog"
  49.       end;
  50.  
  51. end -- EXAMPLE
  52.